package dryven.view.engine.parser.componentinvocation;

import dryven.view.ViewDataDictionary;
import dryven.view.engine.parser.CompilationException;
import dryven.view.engine.parser.ViewDataDeclarationCollection;

public class MixedAttributeBinding implements AttributeBinding {
	
	private Iterable<AttributeBinding> _elements;
	
	public MixedAttributeBinding(Iterable<AttributeBinding> elements) {
		super();
		_elements = elements;
	}

	@Override
	public void compile(ViewDataDeclarationCollection declarations) throws CompilationException {
		for (AttributeBinding binding : _elements) {
			binding.compile(declarations);
		}
	}

	@Override
	public Class<?> getBoundType() {
		return String.class;
	}

	@Override
	public Object getValue(ViewDataDictionary viewData) {
		StringBuilder buffer = new StringBuilder();
		for (AttributeBinding binding : _elements) {
			buffer.append(binding.getValue(viewData).toString());
		}
		return buffer;
	}

	@Override
	public Class<?> getBoundGenericType(int index) {
		return null;
	}

	@Override
	public boolean isLiteral() {
		return false;
	}

}
